﻿<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
		<meta content="yes" name="apple-mobile-web-app-capable" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection" />
		<meta content="emai=no" name="format-detection" />
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_HOST;?>shared/css/shared.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_HOST;?>gene/css/common.css" />
		<link rel="stylesheet" type="text/css" href="<?php echo STATIC_HOST;?>gene/css/bind.css" />
		<script type="text/javascript" src="<?php echo STATIC_HOST;?>shared/js/zepto-1.1.6.js"></script>
		<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
		<script async="" charset="UTF-8" src="//static.meiqia.com/dist/meiqia.js?v=20"></script>
		<script type='text/javascript'>
			(function(m, ei, q, i, a, j, s) {
				m[a] = m[a] || function() {
						(m[a].a = m[a].a || []).push(arguments)
					};
				j = ei.createElement(q),
					s = ei.getElementsByTagName(q)[0];
				j.async = true;
				j.charset = 'UTF-8';
				j.src = i + '?v=' + new Date().getUTCDate();
				s.parentNode.insertBefore(j, s);
			})(window, document, 'script', '//static.meiqia.com/dist/meiqia.js', '_MEIQIA');
			_MEIQIA('entId', '20405');
			_MEIQIA('withoutBtn');
			_MEIQIA('init');
		</script>
		<script>
			Zepto(function ($) {
				wx.config({
					debug: false,
					appId: '<?php echo $js_config['appId']?>',
					timestamp: <?php echo $js_config['timestamp']?>,
					nonceStr: '<?php echo $js_config['noncestr']?>',
					signature: '<?php echo $js_config['signature']?>',
					jsApiList: [
						<?php if($product_id == 2): ?>
						'onMenuShareTimeline',
		                'onMenuShareAppMessage',
						<?php endif;?>
						'scanQRCode'
					]
				});
				wx.ready(function() {
					// 扫描二维码并返回结果
					$('#btn-scan').click(function(e) {
						wx.scanQRCode({
							needResult: 1,
							desc: '扫描样本ID',
							success: function(res) {
								var qrcodeStr=res.resultStr;
								qrcodeStr= qrcodeStr.substring(qrcodeStr.length-13,qrcodeStr.length);
								checkQRcode(qrcodeStr);
							}
						});
					});

					<?php if($product_id == 2):?>
					
					wx.onMenuShareTimeline({
		                title: '<?php echo $jsapi['share_title'];?>',
		                link: '<?php echo $jsapi['share_url']?>', // 分享链接
		                imgUrl: 'http://wx.zhishimama.com/img/salon_offline.png', // 分享图标
		                success: function () {
		                    // 用户确认分享后执行的回调函数
		                },
		                cancel: function () {
		                    // 用户取消分享后执行的回调函数
		                }
		            });

		            wx.onMenuShareAppMessage({
		                title: '<?php echo $jsapi['share_title']?>',
		                desc: '<?php echo $jsapi['share_content'];?>', // 分享描述
		                link: '<?php echo $jsapi['share_url']?>', // 分享链接
		                imgUrl: 'http://wx.zhishimama.com/img/salon_offline.png', // 分享图标
		                type: 'link', // 分享类型,music、video或link，不填默认为link
		                dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
		                success: function () {
		                    // 用户确认分享后执行的回调函数
		                },
		                cancel: function () {
		                    // 用户取消分享后执行的回调函数
		                }
		            });
					
					<?php endif;?>
					
				});
				
				function onBridgeReady(){
					<?php if($product_id != 2):?>
					WeixinJSBridge.call('hideOptionMenu');
					<?php endif;?>
				}

				if (typeof WeixinJSBridge == "undefined"){
					if( document.addEventListener ){
						document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
					}else if (document.attachEvent){
						document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
						document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
					}
				}else{
					onBridgeReady();
				}
				$(".popup-bind a.btn").live('click', function() {
					zsmm.isValidated = true;
					var qrcodeStr = $(this).siblings("input").val();
					validateQRcode(qrcodeStr);
					if(zsmm.isValidated) {
						checkQRcode(qrcodeStr);
					}
				});
			});

			function validateQRcode(str) {
				var Expression = /^\d{<?php echo $product_html['bind_check_length']  ?>}$/;
				if(!(Expression.test(str))) {
					zsmm.Toast.New('格式不正确!');
					zsmm.isValidated = false;
				}
			}

			function checkQRcode(qrcode) {
				$.ajax({
					type: 'post',
					url: "/bind/sample/scanqrcode",
					data: {
						'qrcode': qrcode
					},
					dataType: 'json',
					success: function(res) {
						if(res.error == 0) {
							zsmm.Toast.New(res.msg);
							window.location.href = '/bind/sample/info?bindno=' + qrcode + '&bindid='+ res.info.bind_id ;
						} else {
							zsmm.Toast.New(res.msg);
						}
					}
				});
			}
		</script>
		<title>样本绑定</title>
	</head>
	<body>
		<div class="wrapper">
			<header>
				<p class="status s-bind1"></p>
			</header>
			<section class="qrcode">
				<p class="title">请扫描套件码完成绑定</p>
				<!-- <img class="fullScreen" src="<?php echo STATIC_HOST;?>gene/img/step.jpg" alt="" /> -->
				<?php echo $product_html['bind_img'] ?>
				<button id ="btn-scan" class="btn btn-orange">扫码绑定</button>
				<a class="" data-href="javascript:zsmm.Popup.New($('.popup-bind'),0)">手动输入套件码绑定</a>
			</section>
			<ul class="steps">
				<?php echo $product_html['bind_html'] ?>
			</ul>
			<section class="follow-notice">
				<?php echo $product_html['code'] ?>
			</section>
			<ul class="service-notice flex-wrapper flex-pack-justify">
				<li>
					<a href="javascript:void(0)" onclick="_MEIQIA('showPanel')"><img src="<?php echo STATIC_HOST;?>gene/img/d_online.png"></a>
				</li>
				<li>
					<a href="tel:4008210418"><img src="<?php echo STATIC_HOST;?>gene/img/d_phone.png"></a>
				</li>
			</ul>
		</div>
		<div class="hide popup-bind">
			<span id="close" data-href="javascript:zsmm.Popup.clear();"><img class="fullScreen" src="<?php echo STATIC_HOST;?>gene/img/i_close.png" /></span>
			<input  type="number" name="qrcode" oninput="if(value.length><?php echo $product_html['bind_check_length']  ?>)value=value.slice(0,<?php echo $product_html['bind_check_length']  ?>)"  placeholder="输入<?php echo $product_html['bind_check_length']  ?>位套件码" value="" />
			<a class="btn btn-orange" id="qrcode-submit" href="javascript:void(0);">确 定</a>
		</div>
		<footer>
			<ul>
				<li>
					<a href="/bind/sample/index?id=<?php echo $product_id?>" class="btn btn-green"><span class="icon icon-blood"></span>样本绑定</a>
				</li>
				<li>
					<a href="/product/detail?id=<?php echo $product_id?>" class="btn btn-blue"><span class="icon icon-book"></span>预 约</a>
				</li>
				<li>
					<a href="/sale/check/index?id=<?php echo $product_id?>" class="btn btn-red"><span class="icon icon-test"></span>我的检测</a>
				</li>
			</ul>
		</footer>
		<script type="text/javascript" src="<?php echo STATIC_HOST;?>shared/js/shared.js"></script>
	</body>
</html>